#include <iostream>
using namespace std;


int main(){
	int t;
	cin>>t;
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int h=0;h<t;h++){
		int xmin=0,sum=n;
		while(true){
			cout<<h<<":"<<a[n-1]-a[xmin]<<endl;
			if(a[n-1]-a[xmin] <= a[n-2])
				break;
			else{
				sum--;
				a[n-1] -= a[xmin];
				xmin++;
			}
		}
		cout<<sum<<endl;
		if(h == t-1)
			break;
		int k;
		cin>>k;
		for(int i=0;i<k;i++){
			int x,y;
			cin>>x>>y;
			a[x-1] = y;
		}
	}
}
